package Jihe;
import java.util.ArrayList;

import java.util.Scanner;

public class  Ktvsongsystem{

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        ArrayList list = new ArrayList();
        list.add("爱");
        list.add("安和桥");
        list.add("消愁");
        list.add("恋人心");

        boolean a = true;


        while (a) {
            System.out.println();
            System.out.println("----------------------------欢迎来到点歌系统---------------------------");
            System.out.println("指令1代表添加歌曲");
            System.out.println("指令2代表将所选歌曲置顶");
            System.out.println("指令3代表将所选歌曲提前一位");
            System.out.println("指令4代表退出该系统");
            System.out.println("指令5代表查看所有歌曲信息");
            System.out.println("指令6代表删除歌曲信息" + "\n");

            ArrayList list1 = new ArrayList();
            list1.add(1);
            list1.add(2);
            list1.add(3);
            list1.add(4);
            list1.add(5);
            list1.add(6);
            System.out.print("请输入你的指令(1~6):");
            int a1 = scanner.nextInt();

            if (list1.indexOf(a1) != -1) {
                if (a1 == 1) {
                    System.out.print("请输入你要添加的歌曲:");
                    list.add(scanner.next());
                    System.out.println("歌曲添加成功!");
                    for (int i = 0; i < list.size(); i++) {
                        System.out.println("列表" + (list.indexOf(list.get(i)) + 1) + "-----" + list.get(i));
                    }
                } else if (a1 == 2) {
                    System.out.print("请输入你需要置顶的歌曲:");
                    String ge1 = scanner.next();
                    int b1 = list.indexOf(ge1);
                    if (list.indexOf(ge1) != -1) {
                        list.add(0, ge1);
                        list.remove(b1 + 1);
                        for (int i = 0; i < list.size(); i++) {
                            System.out.println("列表" + (list.indexOf(list.get(i)) + 1) + "-----" + list.get(i));
                        }
                    } else {
                        System.out.println("列表中没有该歌曲,请先添加歌曲");
                        System.out.print("是否添加该歌曲");
                        String b = scanner.next();
                        if (b.equals("是")) {
                            list.add(list.size(), ge1);
                            System.out.println("添加成功!");
                            for (int i = 0; i < list.size(); i++) {
                                System.out.println("列表" + (list.indexOf(list.get(i)) + 1) +
                                        "-----" + list.get(i));
                            }
                        }
                    }
                } else if (a1 == 3) {
                    System.out.print("请输入你选择上移一位的歌曲:");
                    String ge3 = scanner.next();
                    if (list.indexOf(ge3) != -1 && list.indexOf(ge3) !=0) {
                        int c = list.indexOf(ge3);
                        list.add(c-1,ge3);
                        list.remove(c+1);
                        for (int i = 0; i < list.size(); i++) {
                            System.out.println("列表" + (list.indexOf(list.get(i)) + 1) + "-----" + list.get(i));
                        }
                    } else {
                        System.out.println("列表中没有该歌曲,或该歌曲已置顶,请先添加歌曲");
                        System.out.print("是否添加该歌曲");
                        String b = scanner.next();
                        if (b.equals("是")) {
                            list.add(list.size(), ge3);
                            System.out.println("添加成功!");
                            for (int i = 0; i < list.size(); i++) {
                                System.out.println("列表" + (list.indexOf(list.get(i)) + 1) +
                                        "-----" + list.get(i));
                            }
                        }
                    }
                } else if (a1 == 4) {
                    System.out.println("已退出点歌系统");
                    a = false;
                } else if (a1 == 5) {
                    for (int i = 0; i < list.size(); i++) {
                        System.out.println("列表" + (list.indexOf(list.get(i)) + 1) +
                                "-----" + list.get(i));
                    }
                } else if (a1 == 6) {
                    System.out.println("请输入你需要清除的歌曲:");
                    String ge2 = scanner.next();
                    if (list.indexOf(ge2) != -1) {
                        list.remove(list.indexOf(ge2));
                        for (int i = 0; i < list.size(); i++) {
                            System.out.println("列表" + (list.indexOf(list.get(i)) + 1) + "-----" + list.get(i));
                        }
                    } else {
                        System.out.println("列表中没有该歌曲,请先添加歌曲");
                    }
                }
            } else {
                System.out.println("您输入的指令有误,请重新输入!");
            }

        }
        scanner.close();
    }
}